package com.easy.service.impl;

import com.easy.bean.Production_schedule;
import com.easy.mapper.ProductionScheduleDao;
import com.easy.service.ProductionScheduleService;
import com.easy.util.Page;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class ProductionScheduleServiceImpl implements ProductionScheduleService {

    @Autowired
    ProductionScheduleDao productionScheduleDao;

    @Override
    public Production_schedule add(Production_schedule schedule) {
        productionScheduleDao.add(schedule);
        return productionScheduleDao.one(schedule.getId());
    }

    @Override
    public int del(Integer id) {
        return productionScheduleDao.del(id);
    }

    @Override
    public Production_schedule edit(Production_schedule schedule) {
        productionScheduleDao.edit(schedule);
        return productionScheduleDao.one(schedule.getId());
    }

    @Override
    public List<Production_schedule> all(Integer productionOrderId, Integer assignedEmployeeId) {
        return productionScheduleDao.all(productionOrderId, assignedEmployeeId);
    }

    @Override
    public Production_schedule one(Integer id) {
        return productionScheduleDao.one(id);
    }

    @Override
    public void page(Page page, Production_schedule schedule) {
        int count = productionScheduleDao.pageCount(schedule);
        List<Production_schedule> data = productionScheduleDao.page(page, schedule);
        page.setCount(count);
        page.setData(data);
    }
}
